package com.daxt.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.daxt.common.annotations.OperLog;
import com.daxt.common.result.Result;
import com.daxt.common.result.ResultUtil;
import com.daxt.model.dic.DicDocFileType;
import com.daxt.model.dic.DicDocFrom;
import com.daxt.model.dto.ArchivesStatisticsParamDto;
import com.daxt.model.dto.BaseExportParam;
import com.daxt.model.dto.Classifys;
import com.daxt.model.service.archives.param.AddCol;
import com.daxt.model.service.archives.result.ArchivesTypeCols;
import com.daxt.model.service.archives.vo.*;
import com.daxt.model.service.base.result.UserInfo;
import com.daxt.model.service.select.ExportParam;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.List;
import java.util.Map;

public interface ArchivesService {


	/**
	 * @description: 导入路桥卷内目录
	 */
	Result<String> importLqArchives(BaseExportParam exportParam);


	/**
	 * @description: 自动生成卷件号
	 *
	 * @return success成功
	 */
	Result<String> automationDossierItemNumNum(ArchivesType at,String fileType,String classId,String fondsId,List<String> ids);

	/**
	 * @description: 构造档案号
	 *
	 * @param sole 是否唯一
	 * @return success成功
	 *
	 * @author: lig
	 * @date: 2021/6/9
	 */
	Result<String> buildArchivalNum(ArchivesDoc archivesDoc, ArchivesType archivesType,boolean sole);


	/**
	 * @description: 构造输出内容，字典key转换
	 *
	 * @author: lig
	 * @date: 2021/7/5
	 */
	ArchivesDoc builArchivesDocOut(ArchivesDoc doc);

	/**
	 * @description: 构造数据权限查询条件
	 *
	 * @author: lig
	 * @date: 2021-07-07
	 */
	QueryWrapper<ArchivesDoc> builQueryWrapper(QueryWrapper<ArchivesDoc> queryWrapper, Classifys c);

	/**
	 * @description: 增加档案统计
	 *
	 * @author: lig
	 * @date: 2021-08-03
	 */
	void addCount(String fonds, String type,String pattern,String year);




	/**
	 * @description: 校验件号重复
	 *
	 * @author: lig
	 * @date: 2021/8/4
	 */
	public boolean verifyDocNum(ArchivesDoc adBean);

	/**
	 * @description: 校验件号重复,升级改造
	 *
	 * @author: lig
	 * @date: 2022/9/15
	 */
	public boolean verifyDocNumNew(ArchivesDoc adBean,List<String> ids);

	/**
	 * @description: 卷件模式 - 校验 件号重复
	 *
	 * @author: lig
	 * @date: 2021/8/4
	 */
	boolean verifyDDDoc(ArchivesDoc adBean);


	/**
	 * @description: 全件模式 - 校验 件号重复
	 *
	 * @author: lig
	 * @date: 2021/8/4
	 */
	boolean verifyDDoc(ArchivesDoc adBean);


	/**
	 * @description: 规则匹配   组卷
	 *
	 * @author: lig
	 * @date: 2021/8/4
	 */
	public boolean matchingConstitute(ArchivesDoc dossier ,ArchivesDoc doc,ArchivesType at);
//	/**
//	 * @description: 规则匹配   组卷
//	 *
//	 * @author: lig
//	 * @date: 2021/8/4
//	 */
//	public boolean matchingConstitute(ArchivesDoc adBean);


	/**
	 * @description: 校验案卷号重复
	 * @author: lig
	 * @date: 2021/8/5
	 */
	public boolean verifyDossierNum(ArchivesDoc adBean);

	/**
	 * @description: 校验案卷号重复,升级改造版
	 *
	 * @author: lig
	 * @date: 2022/9/15
	 */
	public boolean verifyDossierNumNew(ArchivesDoc adBean,List<String> ids);

	/**
	 * @description: 校验分类号重复
	 * @author: lig
	 * @date: 2021/8/5
	 */
	public boolean verifyClassNumRepetition(ArchivesClass archivesClass);


	/**
	 * @description: 重复验证规则语句
	 * @author: lig
	 * @date: 2021/8/5
	 */
	public QueryWrapper<ArchivesDoc> verifyRepetitionQueryWrapper(ArchivesDoc adBean);

	/**
	 * @description: 存在归档文件
	 * @author: lig
	 * @date: 2021/6/21
	 */
	boolean existArchive(ArchivesDoc doc);

    /**
     * @description: 构造分类号
     *
     * @return 第一级分类/第二级分类/第三级分类。。。。
     *
     * @author: lig
     * @date: 2021-08-11
     */
    String buildClassNum(String fondsId, String typeNum,String classNum);



    /**
     * @description: 内容为KEY
     *
     * @author: lig
     * @date: 2021/10/12
     */
	Map<String,Map<String,String>> buildDic();

    /**
     * @description:  正常key
     *
     * @author: lig
     * @date: 2021-12-17
     */
	Map<String,Map<String,String>> buildBaseDic();



	/**
	 * @description: 导入文档
	 *
	 * @author: lig
	 * @date: 2021/10/12
	 */
	Result<String> importArchives(ExportParam exportParam);



	/**
	 * @description: 构造文件名称
	 * @author: lig
	 * @date: 2021-07-23
	 */
	String buildFileName(File tempFile, ArchivesDoc doc, String pattern);


	/**
	 * @description: 解析分类树结构
	 * @author: lig
	 * @date: 2021-12-09
	 */
	void parseClassNum(ArchivesDoc archivesDossier);


	/**
	 * @description: 获取件
	 *
	 * @author: lig
	 * @date: 2022/1/12
	 */
	List<ArchivesDoc> gainDocById(String docId);

	/**
	 * @description: 档案加入检索库
	 *
	 * @author: lig
	 * @date: 2022-01-17
	 */
	void addArticle(List<String> ids);

	/**
	 * @description:  获取件列表
	 *
	 * @author: lig
	 * @date: 2022-01-18
	 */
	List<ArchivesDoc> gainDocList(List<ArchivesDoc> srcDocList);

	/**
	 * @description: 构造统计查询条件
	 *
	 * @author: lig
	 * @date: 2022/1/19
	 */
	QueryWrapper<ArchivesDoc> buildStatisticsQueryWrapper(QueryWrapper<ArchivesDoc> queryWrapperDoc, ArchivesStatisticsParamDto paramDto);


	/**
	 * @description: 获取统计门类
	 *
	 * @author: lig
	 * @date: 2022/1/19
	 */
	List<ArchivesDoc> gainStatisticsType(ArchivesStatisticsParamDto paramDto);



	//=========统计 start

	Integer statisticsFonds(String fondsId);
	Integer statisticsType(String fondsId,String typeId);
	Integer statisticsArchives(ArchivesStatisticsParamDto paramDto);
	Integer statisticsArchivesFrom( DicDocFrom dicDocFrom, DicDocFileType dicDocFileType,String fondsId,String typeId);

	//=========统计 end
	String gainDocFileList(Map<String, Object> filesParamFromDoc1);


//	/**
//	 * @description: 分类  获取父类
//	 *
//	 * @author: lig
//	 * @date: 2021/10/14
//	 */
//	ArchivesClass parentClass(long classId);



    /**
     * @description: 获取基础字段
     *
     * @author: lig
     * @date: 2022/2/22
     */
    List<ArchivesTypeDoc> gainBaseField(String fileType, String typeId);

    /**
     * @description: 获取基础查询字段
     *
     * @author: lig
     * @date: 2022/2/22
     */
    List<String> gainBaseQueryField(String fileType, String typeId);



    /**
     * @description: 四性检测
     *
     * @author: lig
     * @date: 2022/2/24
     */
	Result fourDetection(ArchivesDocReceive adr);


	/**
	 * @description: 删除档案附件
	 *
	 * @author: lig
	 * @date: 2022/2/28
	 */
	Result deleteFile(List<ArchivesDocFile> list);



	/**
	 * @description: 构造基础信息
	 *
	 * @author: lig
	 * @date: 2022/3/24
	 */
	void buildBaseInfo(ArchivesDoc doc);

	/**
	 * 创建档案xml文件
	 */
	void createArchivesXml(List<String> ids,String fileType, Long userId , HttpServletRequest request,String docTotalSize);

	/**
	 * 保存档案持久化文件
	 * @param ids
	 * @param fondsId
	 * @param typeId
	 * @param classId
	 * @param fileType
	 * @return 返回文件的大小
	 */
	String saveArchivesDurableFile(List<String> ids, String fondsId, String typeId, String classId, String fileType);

	/**
	 * 获取元数据可编辑的字段
	 * @return
	 */
	Map<String,String> gainMetadataEditField(Long typeId,String fileType);
}
